package view;

import java.awt.Color;
import java.util.*;

import javax.swing.*;

import vossenenkonijnen.Actor;

import controller.Field;
import controller.FieldStats;

/**
 * Write a description of class TextView here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */

public  class TextView extends JFrame implements SimulatorView
{
    // instance variables.
        private FieldStats stats;
        private HashMap<Class, Color> colors;
        
    /**
     * Constructor for objects of class TextView
     */
    public TextView()
    {
    	stats = new FieldStats();
        colors = new LinkedHashMap<Class, Color>();
                
    }
    
    @Override
    public void showStatus(int step, Field field)
    {

        stats.reset();
        
        for(int row = 0; row < field.getDepth(); row++) {
            for(int col = 0; col < field.getWidth(); col++) {
                Actor actor = field.getObjectAt(row, col);
                if(actor != null) {
                    stats.incrementCount(actor.getClass());
                }
            }
        }
                
        stats.countFinished();
        
        String x = stats.getPopulationDetails(field);
        System.out.println(x);
    }
    
    @Override
    public boolean isViable(Field field)
    {
        return stats.isViable(field);
    }
    
    @Override
    public void setColor(Class animalClass, Color color)
    {
        colors.put(animalClass, color);
    }
}